import { useMainStore } from '@/store/useMainStore'
import { useRegionStore } from '@/store/useRegionStore'
import { useSessionStorage } from '@vueuse/core'
import { StorageEnum } from '@/core/enums/shared'

export function useUserExpired() {
  const mainStore = useMainStore()
  const regionStore = useRegionStore()
  const reloadTag = useSessionStorage<string | null>(StorageEnum.ReloadTag, null)

  return {
    expired() {
      mainStore.removeUserInfo()
      mainStore.removeToken()
      regionStore.removeRegion()
      reloadTag.value = '1'
      window.location.reload()
    }
  }
}
